\hypertarget{arrayutils_8h}{
\subsection{arrayutils.h File Reference}
\label{arrayutils_8h}\index{arrayutils.h@{arrayutils.h}}
}


Functions to convert arrays in both directions: Java -\/$>$ Python and Python -\/$>$ Java.  


\subsubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
{\footnotesize template$<$typename From , typename FromBaseType $>$ }\\PyObject $\ast$ \hyperlink{arrayutils_8h_a7c2b9d88a8e9000f8eba4f111f8fd9d8}{convertJavaArrayToPythonArray} (JNIEnv $\ast$\hyperlink{_python_calls_java_8cc_ae6f0d0cd46e56b7e299b489cb60dd27e}{env}, From array, char resType)
\begin{DoxyCompactList}\small\item\em Converts {\ttfamily Java} array in to the {\ttfamily Python} tuple. \item\end{DoxyCompactList}\item 
{\footnotesize template$<$$>$ }\\PyObject $\ast$ \hyperlink{arrayutils_8h_a6214acebdfe624a0ad33de1b8033f10e}{convertJavaArrayToPythonArray$<$ jdoubleArray, jdouble $>$} (JNIEnv $\ast$\hyperlink{_python_calls_java_8cc_ae6f0d0cd46e56b7e299b489cb60dd27e}{env}, jdoubleArray array, char resType)
\begin{DoxyCompactList}\small\item\em Converts {\ttfamily Java} array {\ttfamily jdoubleArray} in to the {\ttfamily Python} tuple. \item\end{DoxyCompactList}\item 
{\footnotesize template$<$$>$ }\\PyObject $\ast$ \hyperlink{arrayutils_8h_a4d445f8e1b6650d912714be0f892b8ce}{convertJavaArrayToPythonArray$<$ jfloatArray, jfloat $>$} (JNIEnv $\ast$\hyperlink{_python_calls_java_8cc_ae6f0d0cd46e56b7e299b489cb60dd27e}{env}, jfloatArray array, char resType)
\begin{DoxyCompactList}\small\item\em Converts {\ttfamily Java} array {\ttfamily jfloatArray} in to the {\ttfamily Python} tuple. \item\end{DoxyCompactList}\item 
{\footnotesize template$<$$>$ }\\PyObject $\ast$ \hyperlink{arrayutils_8h_a8bd23fc9365c7cf07e1bdf11ed0617fc}{convertJavaArrayToPythonArray$<$ jobjectArray, jobject $>$} (JNIEnv $\ast$\hyperlink{_python_calls_java_8cc_ae6f0d0cd46e56b7e299b489cb60dd27e}{env}, jobjectArray array, char resType)
\begin{DoxyCompactList}\small\item\em Converts {\ttfamily Java} array {\ttfamily jobjectArray} in to the {\ttfamily Python} tuple. \item\end{DoxyCompactList}\item 
{\footnotesize template$<$typename From , typename To , typename ToBaseType $>$ }\\To \hyperlink{arrayutils_8h_a6cdb791cac61a87e7620f0f30b61ede9}{convertPythonArrayToJavaArray} (JNIEnv $\ast$\hyperlink{_python_calls_java_8cc_ae6f0d0cd46e56b7e299b489cb60dd27e}{env}, From $\ast$array, char type, unsigned int size)
\begin{DoxyCompactList}\small\item\em Creates new {\ttfamily Java} array of type {\ttfamily To} from native {\ttfamily C++} array of type {\ttfamily From} Creates new {\ttfamily Java} array using {\ttfamily newJavaArrayByType} function, copies elements from the native. \item\end{DoxyCompactList}\item 
{\footnotesize template$<$$>$ }\\jobjectArray \hyperlink{arrayutils_8h_a2faf58bec61486318377ee9d9b3d82c8}{convertPythonArrayToJavaArray$<$ char $\ast$, jobjectArray, jobject $>$} (JNIEnv $\ast$\hyperlink{_python_calls_java_8cc_ae6f0d0cd46e56b7e299b489cb60dd27e}{env}, char $\ast$$\ast$array, char type, unsigned int size)
\begin{DoxyCompactList}\small\item\em Creates new {\ttfamily Java} array of type {\ttfamily jobjectArray} from native {\ttfamily C++} array of type {\ttfamily char$\ast$}. \item\end{DoxyCompactList}\item 
{\footnotesize template$<$typename To $>$ }\\To \hyperlink{arrayutils_8h_af4c50dac617ae9a8ff03576122b18e7e}{newJavaArrayByType} (JNIEnv $\ast$\hyperlink{_python_calls_java_8cc_ae6f0d0cd46e56b7e299b489cb60dd27e}{env}, char type, unsigned int size)
\begin{DoxyCompactList}\small\item\em Generalizes call of the {\ttfamily New$<$Type$>$Array} {\ttfamily JNI} function. \item\end{DoxyCompactList}\item 
{\footnotesize template$<$typename From $>$ }\\PyObject $\ast$ \hyperlink{arrayutils_8h_ae900ad4fd14dae537cb35ea7009c7100}{PyObject\_\-FromJObject} (From jobj, char resType)
\begin{DoxyCompactList}\small\item\em Creates {\ttfamily Python} object from basic {\ttfamily C++} native type. \item\end{DoxyCompactList}\item 
{\footnotesize template$<$typename To , typename ToBaseType $>$ }\\void \hyperlink{arrayutils_8h_a0043c3fa94f497e44c9683c89978af57}{setTJavaArrayRegion} (JNIEnv $\ast$\hyperlink{_python_calls_java_8cc_ae6f0d0cd46e56b7e299b489cb60dd27e}{env}, char type, To dest, unsigned int start, unsigned int size, ToBaseType $\ast$src)
\begin{DoxyCompactList}\small\item\em Generalizes call of the {\ttfamily Set$<$Type$>$ArrayRegion} {\ttfamily JNI} function. \item\end{DoxyCompactList}\end{DoxyCompactItemize}


\subsubsection{Detailed Description}
Functions to convert arrays in both directions: Java -\/$>$ Python and Python -\/$>$ Java. \begin{DoxyAuthor}{Author}
Sergey.Karakovskiy at idsia.ch, Nikolay.Sohryakov at gmail.com
\end{DoxyAuthor}
\begin{DoxyVersion}{Version}
0.1
\end{DoxyVersion}
Types symbols: \begin{DoxyItemize}
\item V -\/ void \item Z -\/ boolean \item B -\/ byte \item C -\/ char \item S -\/ short \item I -\/ int \item J -\/ long \item F -\/ float \item D -\/ double \item L -\/ string \end{DoxyItemize}


Definition in file \hyperlink{arrayutils_8h_source}{arrayutils.h}.



\subsubsection{Function Documentation}
\hypertarget{arrayutils_8h_a7c2b9d88a8e9000f8eba4f111f8fd9d8}{
\index{arrayutils.h@{arrayutils.h}!convertJavaArrayToPythonArray@{convertJavaArrayToPythonArray}}
\index{convertJavaArrayToPythonArray@{convertJavaArrayToPythonArray}!arrayutils.h@{arrayutils.h}}
\paragraph[{convertJavaArrayToPythonArray}]{\setlength{\rightskip}{0pt plus 5cm}PyObject$\ast$ convertJavaArrayToPythonArray (JNIEnv $\ast$ {\em env}, \/  From {\em array}, \/  char {\em resType})\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}\hfill}
\label{arrayutils_8h_a7c2b9d88a8e9000f8eba4f111f8fd9d8}


Converts {\ttfamily Java} array in to the {\ttfamily Python} tuple. 

Converts each element of the {\ttfamily Java} array in to the {\ttfamily PyObject$\ast$} and puts it in the {\ttfamily Python} tuple. Instantiated for: {\ttfamily jfloatArray}, {\ttfamily jdoubleArray}, {\ttfamily jobjectArray} (array of strings).


\begin{DoxyParams}{Parameters}
\item[{\em env}]Pointer to the {\ttfamily JNIEnv} \item[{\em array}]{\ttfamily Java} array to be converted \item[{\em resType}]Type of elements of the {\ttfamily array} given as char\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Pointer to the {\ttfamily Python} object ({\ttfamily PyObject$\ast$}) 
\end{DoxyReturn}


Definition at line 263 of file arrayutils.h.

\hypertarget{arrayutils_8h_a6214acebdfe624a0ad33de1b8033f10e}{
\index{arrayutils.h@{arrayutils.h}!convertJavaArrayToPythonArray$<$ jdoubleArray, jdouble $>$@{convertJavaArrayToPythonArray$<$ jdoubleArray, jdouble $>$}}
\index{convertJavaArrayToPythonArray$<$ jdoubleArray, jdouble $>$@{convertJavaArrayToPythonArray$<$ jdoubleArray, jdouble $>$}!arrayutils.h@{arrayutils.h}}
\paragraph[{convertJavaArrayToPythonArray$<$ jdoubleArray, jdouble $>$}]{\setlength{\rightskip}{0pt plus 5cm}PyObject$\ast$ convertJavaArrayToPythonArray$<$ jdoubleArray, jdouble $>$ (JNIEnv $\ast$ {\em env}, \/  jdoubleArray {\em array}, \/  char {\em resType})\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}\hfill}
\label{arrayutils_8h_a6214acebdfe624a0ad33de1b8033f10e}


Converts {\ttfamily Java} array {\ttfamily jdoubleArray} in to the {\ttfamily Python} tuple. 

Converts each element of the {\ttfamily Java} array in to the {\ttfamily PyObject$\ast$} and puts it in the {\ttfamily Python} tuple.


\begin{DoxyParams}{Parameters}
\item[{\em env}]Pointer to the {\ttfamily JNIEnv} \item[{\em array}]{\ttfamily Java} array to be converted \item[{\em resType}]Type of elements of the {\ttfamily array} given as char\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Pointer to the {\ttfamily Python} object ({\ttfamily PyObject$\ast$}) 
\end{DoxyReturn}
\hypertarget{arrayutils_8h_a4d445f8e1b6650d912714be0f892b8ce}{
\index{arrayutils.h@{arrayutils.h}!convertJavaArrayToPythonArray$<$ jfloatArray, jfloat $>$@{convertJavaArrayToPythonArray$<$ jfloatArray, jfloat $>$}}
\index{convertJavaArrayToPythonArray$<$ jfloatArray, jfloat $>$@{convertJavaArrayToPythonArray$<$ jfloatArray, jfloat $>$}!arrayutils.h@{arrayutils.h}}
\paragraph[{convertJavaArrayToPythonArray$<$ jfloatArray, jfloat $>$}]{\setlength{\rightskip}{0pt plus 5cm}PyObject$\ast$ convertJavaArrayToPythonArray$<$ jfloatArray, jfloat $>$ (JNIEnv $\ast$ {\em env}, \/  jfloatArray {\em array}, \/  char {\em resType})\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}\hfill}
\label{arrayutils_8h_a4d445f8e1b6650d912714be0f892b8ce}


Converts {\ttfamily Java} array {\ttfamily jfloatArray} in to the {\ttfamily Python} tuple. 

Converts each element of the {\ttfamily Java} array in to the {\ttfamily PyObject$\ast$} and puts it in the {\ttfamily Python} tuple.


\begin{DoxyParams}{Parameters}
\item[{\em env}]Pointer to the {\ttfamily JNIEnv} \item[{\em array}]{\ttfamily Java} array to be converted \item[{\em resType}]Type of elements of the {\ttfamily array} given as char\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Pointer to the {\ttfamily Python} object ({\ttfamily PyObject$\ast$}) 
\end{DoxyReturn}
\hypertarget{arrayutils_8h_a8bd23fc9365c7cf07e1bdf11ed0617fc}{
\index{arrayutils.h@{arrayutils.h}!convertJavaArrayToPythonArray$<$ jobjectArray, jobject $>$@{convertJavaArrayToPythonArray$<$ jobjectArray, jobject $>$}}
\index{convertJavaArrayToPythonArray$<$ jobjectArray, jobject $>$@{convertJavaArrayToPythonArray$<$ jobjectArray, jobject $>$}!arrayutils.h@{arrayutils.h}}
\paragraph[{convertJavaArrayToPythonArray$<$ jobjectArray, jobject $>$}]{\setlength{\rightskip}{0pt plus 5cm}PyObject$\ast$ convertJavaArrayToPythonArray$<$ jobjectArray, jobject $>$ (JNIEnv $\ast$ {\em env}, \/  jobjectArray {\em array}, \/  char {\em resType})\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}\hfill}
\label{arrayutils_8h_a8bd23fc9365c7cf07e1bdf11ed0617fc}


Converts {\ttfamily Java} array {\ttfamily jobjectArray} in to the {\ttfamily Python} tuple. 

Converts each element of the {\ttfamily Java} array in to the {\ttfamily PyObject$\ast$} and puts it in the {\ttfamily Python} tuple.


\begin{DoxyParams}{Parameters}
\item[{\em env}]Pointer to the {\ttfamily JNIEnv} \item[{\em array}]{\ttfamily Java} array to be converted \item[{\em resType}]Type of elements of the {\ttfamily array} given as char\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Pointer to the {\ttfamily Python} object ({\ttfamily PyObject$\ast$}) 
\end{DoxyReturn}
\hypertarget{arrayutils_8h_a6cdb791cac61a87e7620f0f30b61ede9}{
\index{arrayutils.h@{arrayutils.h}!convertPythonArrayToJavaArray@{convertPythonArrayToJavaArray}}
\index{convertPythonArrayToJavaArray@{convertPythonArrayToJavaArray}!arrayutils.h@{arrayutils.h}}
\paragraph[{convertPythonArrayToJavaArray}]{\setlength{\rightskip}{0pt plus 5cm}To convertPythonArrayToJavaArray (JNIEnv $\ast$ {\em env}, \/  From $\ast$ {\em array}, \/  char {\em type}, \/  unsigned int {\em size})\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}\hfill}
\label{arrayutils_8h_a6cdb791cac61a87e7620f0f30b61ede9}


Creates new {\ttfamily Java} array of type {\ttfamily To} from native {\ttfamily C++} array of type {\ttfamily From} Creates new {\ttfamily Java} array using {\ttfamily newJavaArrayByType} function, copies elements from the native. 

{\ttfamily C++} array and copies this array in to the {\ttfamily JNI} memory using {\ttfamily setTJavaArrayRegion} 


\begin{DoxyParams}{Parameters}
\item[{\em env}]pointer to the JNIEnv \item[{\em array}]native {\ttfamily C++} array to be copied \item[{\em type}]type of the array given as char \item[{\em size}]number of elements in the array\end{DoxyParams}
\begin{DoxyReturn}{Returns}
{\ttfamily Java} array (e.g. jintArray, jfloatArray) 
\end{DoxyReturn}


Definition at line 142 of file arrayutils.h.

\hypertarget{arrayutils_8h_a2faf58bec61486318377ee9d9b3d82c8}{
\index{arrayutils.h@{arrayutils.h}!convertPythonArrayToJavaArray$<$ char $\ast$, jobjectArray, jobject $>$@{convertPythonArrayToJavaArray$<$ char $\ast$, jobjectArray, jobject $>$}}
\index{convertPythonArrayToJavaArray$<$ char $\ast$, jobjectArray, jobject $>$@{convertPythonArrayToJavaArray$<$ char $\ast$, jobjectArray, jobject $>$}!arrayutils.h@{arrayutils.h}}
\paragraph[{convertPythonArrayToJavaArray$<$ char $\ast$, jobjectArray, jobject $>$}]{\setlength{\rightskip}{0pt plus 5cm}jobjectArray convertPythonArrayToJavaArray$<$ char $\ast$, jobjectArray, jobject $>$ (JNIEnv $\ast$ {\em env}, \/  char $\ast$$\ast$ {\em array}, \/  char {\em type}, \/  unsigned int {\em size})\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}\hfill}
\label{arrayutils_8h_a2faf58bec61486318377ee9d9b3d82c8}


Creates new {\ttfamily Java} array of type {\ttfamily jobjectArray} from native {\ttfamily C++} array of type {\ttfamily char$\ast$}. 

Creates new {\ttfamily Java} array of {\ttfamily Java} string from native {\ttfamily C++} array {\ttfamily char$\ast$$\ast$}. Instantiated for: \begin{DoxyItemize}
\item From = char$\ast$ \item To = jobjectArray \item ToBaseType = jobject\end{DoxyItemize}

\begin{DoxyParams}{Parameters}
\item[{\em env}]pointer to the JNIEnv \item[{\em array}]native {\ttfamily C++} array to be copied \item[{\em type}]type of the array given as char \item[{\em size}]number of elements in the array\end{DoxyParams}
\begin{DoxyReturn}{Returns}
{\ttfamily Java} array (e.g. jintArray, jfloatArray) 
\end{DoxyReturn}
\hypertarget{arrayutils_8h_af4c50dac617ae9a8ff03576122b18e7e}{
\index{arrayutils.h@{arrayutils.h}!newJavaArrayByType@{newJavaArrayByType}}
\index{newJavaArrayByType@{newJavaArrayByType}!arrayutils.h@{arrayutils.h}}
\paragraph[{newJavaArrayByType}]{\setlength{\rightskip}{0pt plus 5cm}To newJavaArrayByType (JNIEnv $\ast$ {\em env}, \/  char {\em type}, \/  unsigned int {\em size})\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}\hfill}
\label{arrayutils_8h_af4c50dac617ae9a8ff03576122b18e7e}


Generalizes call of the {\ttfamily New$<$Type$>$Array} {\ttfamily JNI} function. 

Calls New$<$Type$>$Array depend on type given as char(accordingly to JNI types naming). For additional information see Set$<$Type$>$ArrayRegion.


\begin{DoxyParams}{Parameters}
\item[{\em env}]pointer to the JNIEnv \item[{\em type}]type of the array given as char \item[{\em size}]number of elements in the array\end{DoxyParams}
\begin{DoxyReturn}{Returns}
reference to the {\ttfamily Jara} array (e.g. jintArray, jfloatArray) 
\end{DoxyReturn}


Definition at line 103 of file arrayutils.h.

\hypertarget{arrayutils_8h_ae900ad4fd14dae537cb35ea7009c7100}{
\index{arrayutils.h@{arrayutils.h}!PyObject\_\-FromJObject@{PyObject\_\-FromJObject}}
\index{PyObject\_\-FromJObject@{PyObject\_\-FromJObject}!arrayutils.h@{arrayutils.h}}
\paragraph[{PyObject\_\-FromJObject}]{\setlength{\rightskip}{0pt plus 5cm}PyObject$\ast$ PyObject\_\-FromJObject (From {\em jobj}, \/  char {\em resType})\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}\hfill}
\label{arrayutils_8h_ae900ad4fd14dae537cb35ea7009c7100}


Creates {\ttfamily Python} object from basic {\ttfamily C++} native type. 

Calls {\ttfamily PyInt\_\-FromLong} for any type smaller than int, {\ttfamily PyLong\_\-FromLong} for type {\ttfamily long}. This template is instantiated for types {\ttfamily float}, {\ttfamily double} and {\ttfamily string}.


\begin{DoxyParams}{Parameters}
\item[{\em jobj}]Value of basic native type to be converted in to the {\ttfamily PyObject$\ast$} \item[{\em resType}]Type of the {\ttfamily jobj} given as char.\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Pointer to the {\ttfamily Python} object({\ttfamily PyObject$\ast$}). 
\end{DoxyReturn}


Definition at line 225 of file arrayutils.h.

\hypertarget{arrayutils_8h_a0043c3fa94f497e44c9683c89978af57}{
\index{arrayutils.h@{arrayutils.h}!setTJavaArrayRegion@{setTJavaArrayRegion}}
\index{setTJavaArrayRegion@{setTJavaArrayRegion}!arrayutils.h@{arrayutils.h}}
\paragraph[{setTJavaArrayRegion}]{\setlength{\rightskip}{0pt plus 5cm}void setTJavaArrayRegion (JNIEnv $\ast$ {\em env}, \/  char {\em type}, \/  To {\em dest}, \/  unsigned int {\em start}, \/  unsigned int {\em size}, \/  ToBaseType $\ast$ {\em src})\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}\hfill}
\label{arrayutils_8h_a0043c3fa94f497e44c9683c89978af57}


Generalizes call of the {\ttfamily Set$<$Type$>$ArrayRegion} {\ttfamily JNI} function. 

Calls {\ttfamily Set$<$Type$>$ArrayRegion} depend on type given as char in param {\itshape type\/} (accordingly to {\ttfamily JNI} types naming).


\begin{DoxyParams}{Parameters}
\item[{\em env}]pointer to the JNIEnv \item[{\em type}]type of the array given as char \item[{\em dest}]pointer to the java array where data will be copied from the source array(e.g. jintArray, jfloatArray) \item[{\em start}]first index in array to copy from \item[{\em size}]number of array elements to be copied \item[{\em src}]native C++ array to be copied(e.g. jint$\ast$, jfloat$\ast$) \end{DoxyParams}


For type {\ttfamily string} implemented separately in instanciated function {\ttfamily convertPythonArrayToJavaArray}. 



Definition at line 39 of file arrayutils.h.

